﻿@using ByteartRetail.DataObjects;
@using ByteartRetail.Web.MVC

@model UserAccountModel

@{
    ViewBag.Title = "添加用户账户";
}

<hgroup class="title">
    <h1>@Html.Image("User_32.png")&nbsp;@ViewBag.Title</h1>
    <h4>请注意：在此只能创建系统账户，客户账户的创建请使用系统的“注册”功能！</h4>
</hgroup>
@using (Html.BeginForm("AddUserAccount", "Admin", FormMethod.Post, new { id = "AddUserAccountForm" }))
{
    @Html.ValidationSummary(true)

    <div class="editor-label">
        @Html.LabelFor(model => model.UserName)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.UserName)
        @Html.ValidationMessageFor(model => model.UserName)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.Password)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Password)
        @Html.ValidationMessageFor(model => model.Password)
    </div>
    
    <div class="editor-label">
        @Html.LabelFor(model => model.ConfirmPassword)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.ConfirmPassword)
        @Html.ValidationMessageFor(model => model.ConfirmPassword)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.Email)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Email)
        @Html.ValidationMessageFor(model => model.Email)
    </div>
    
    <div class="editor-label">
        @Html.LabelFor(model => model.Role.Name)
    </div>
    <div class="editor-field">
        @Html.DropDownListFor(model => model.Role.ID, (IEnumerable<SelectListItem>)ViewData["roles"])
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.IsDisabled)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.IsDisabled)
        @Html.ValidationMessageFor(model => model.IsDisabled)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.Contact)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Contact)
        @Html.ValidationMessageFor(model => model.Contact)
    </div> 
    
    <div class="editor-label">
        @Html.LabelFor(model => model.PhoneNumber)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.PhoneNumber)
        @Html.ValidationMessageFor(model => model.PhoneNumber)
    </div> 
    
    <p />
    
    <table id="adressTable" style="width: 100%">
        <tr>
            <td style="width: 48%;">
                <fieldset name="contactAddress">
                    <legend>联系地址</legend>
                    <div class="editor-label">
                        @Html.LabelFor(model => model.ContactAddressCountry)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ContactAddressCountry)
                        @Html.ValidationMessageFor(model => model.ContactAddressCountry)
                    </div>


                    <div class="editor-label">
                        @Html.LabelFor(model => model.ContactAddressState)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ContactAddressState)
                        @Html.ValidationMessageFor(model => model.ContactAddressState)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ContactAddressCity)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ContactAddressCity)
                        @Html.ValidationMessageFor(model => model.ContactAddressCity)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ContactAddressStreet)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ContactAddressStreet)
                        @Html.ValidationMessageFor(model => model.ContactAddressStreet)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ContactAddressZip)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ContactAddressZip)
                        @Html.ValidationMessageFor(model => model.ContactAddressZip)
                    </div>
                </fieldset>
            </td>
            <td>
                <img id="copyAddress" src="@Url.Content("~/Images/CopyTo.png")" alt="将联系地址复制到收货地址" title="将联系地址复制到收货地址" border="0" />
            </td>
            <td style="width: 48%;">
                <fieldset name="deliveryAddress">
                    <legend>收货地址</legend>
                    <div class="editor-label">
                        @Html.LabelFor(model => model.DeliveryAddressCountry)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.DeliveryAddressCountry)
                        @Html.ValidationMessageFor(model => model.DeliveryAddressCountry)
                    </div>
                    <div class="editor-label">
                        @Html.LabelFor(model => model.DeliveryAddressState)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.DeliveryAddressState)
                        @Html.ValidationMessageFor(model => model.DeliveryAddressState)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.DeliveryAddressCity)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.DeliveryAddressCity)
                        @Html.ValidationMessageFor(model => model.DeliveryAddressCity)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.DeliveryAddressStreet)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.DeliveryAddressStreet)
                        @Html.ValidationMessageFor(model => model.DeliveryAddressStreet)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.DeliveryAddressZip)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.DeliveryAddressZip)
                        @Html.ValidationMessageFor(model => model.DeliveryAddressZip)
                    </div>
                </fieldset>
            </td>
        </tr>
    </table>

}

<p />

<p>
    <span>@Html.ImageSubmitButton("AddUserAccountForm", Url.Content("~/Images/Save.png"), "保存", "保存更改")</span>
    <span>&nbsp;</span>
    <span>@Html.ImageActionLink(Url.Content("~/Images/Cancel.png"), "取消编辑", "取消编辑", "UserAccounts", "Admin")</span>
</p>


@section scripts {
    <script type="text/javascript">
        $(function () {
            $("#UserName").focus();
            $("#copyAddress").click(function () {
                $("#DeliveryAddressCountry").val($("#ContactAddressCountry").val());
                $("#DeliveryAddressState").val($("#ContactAddressState").val());
                $("#DeliveryAddressCity").val($("#ContactAddressCity").val());
                $("#DeliveryAddressStreet").val($("#ContactAddressStreet").val());
                $("#DeliveryAddressZip").val($("#ContactAddressZip").val());
            });
        });
    </script>
}
